<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:cc="http://java.sun.com/jsf/composite/com">

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
        <link href="./resources/css/cssLayout.css" rel="stylesheet" type="text/css" />
        <link href="./resources/css/stylesheet.css" rel="stylesheet" type="text/css"/>
        <title>Home Page</title>
    </h:head>

    <h:body style="margin: 0 0 0 0">
        <cc:loginRedirect/>
        <div id="top">
            <div class="header">
                <div class="banner"></div>
                <span class="slogan"></span>
                <div class="menu">
                    <h:form>
                        <span>Wellcome : #{loginBean.username}</span> |
                        <span><a href="../faces/home.xhtml">Home</a></span>|
                        <p:commandLink value="Logout" action="#{logoutBean.reset}" />
                    </h:form>
                </div>
            </div>
        </div>
        <div>
            <div id="left">
            </div>
            <div>
                <div id="right">
                </div>
                <div id="content" class="right_content">
                    <p:growl id="messages" showDetail="true"/>
                    <h:form prependId="false">
                        <p:dataTable id="dataTable" var="acc" value="#{allAccountsBean.list}"  paginator="true" rows="10"
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                     rowsPerPageTemplate="10,20,30" selection="#{allAccountsBean.selectAccount}" selectionMode="single"  rowKey="#{acc.acountCode}"
                                     >
                            <f:facet name="header">
                                List Accounts
                            </f:facet>
                            <p:column headerText="AccountCode" filterBy="#{acc.acountCode}">
                                #{acc.acountCode}
                            </p:column>
                            <p:column headerText="Identification Card" filterBy="#{acc.identificationCard}">
                                #{acc.identificationCard}
                            </p:column>
                            <p:column headerText="AccountName" filterBy="#{acc.accountName}">
                                #{acc.accountName}
                            </p:column>
                            <p:column headerText="Address" >
                                #{acc.address}
                            </p:column>
                            <p:column headerText="Balance">
                                <h:outputText value="#{acc.balance}" >
                                    <f:convertNumber type="currency" currencySymbol="VND"/>
                                </h:outputText>

                            </p:column>
                            <p:column headerText="Status">
                                <h:outputText value="#{acc.status}" >
                                    <f:converter converterId="ConvertStatus"  />
                                </h:outputText>
                            </p:column>
                            <p:column headerText="Acction">
                                | <h:link value="Withdrawal" outcome="withdrawal">
                                    <f:param name="accountCode" value="#{acc.acountCode}"/>
                                </h:link> |
                                <h:link value="Transfer" outcome="transfer">
                                    <f:param name="accountCode" value="#{acc.acountCode}"/>
                                </h:link> |<br/>
                                | <h:commandLink value="Lock/UnLock" actionListener="#{allAccountsBean.changeAccount}" >
                                    <f:setPropertyActionListener  value="#{acc}" target="#{allAccountsBean.selectAccount}"/>
                                </h:commandLink> |
                                <h:link value="Deposit" outcome="deposit">
                                    <f:param name="accountCode" value="#{acc.acountCode}"/> <br/>
                                </h:link> |
                                <h:link value="Edit Account" outcome="editAccount">
                                    <f:param name="accountCode" value="#{acc.acountCode}"/>
                                </h:link> |
                            </p:column>
                        </p:dataTable>
                        <hr width="100%"/>
                        <h:commandButton value="Add Account" styleClass="cmdBtn" action="addAccount.xhtml?faces-redirect=true"/> <br/><br/><br/>
                    </h:form>
                    Note: If Status is true, the account is active and vice versa!!
                </div>
            </div>
        </div>
        <div id="bottom">
            <p align="center">Copy Right 2012&copy;<br/>
                Design and code by Group 2 </p>
        </div>

    </h:body>

</html>
